<template>
  <div class="mv-list">
    <ul v-infinite-scroll="load" :infinite-scroll-disabled="disable">
        <li v-for="(item , index) in list" :key="index">
            <div class="mtop-10 img-wrap" @click="toMvdetail(item.id)">
                <el-image
                    style="width: 100%; height: auto; border-radius: 4px"
                    :src="item.cover?item.cover:item.imgurl"
                >
                    <template v-slot:placeholder>
                        <img src="@/assets/img/loading-2.gif" alt="">
                    </template>
                </el-image>
                <div class="video-playcount font-12">
                    <i class="el-icon-video-play icon"></i>
                    {{item.playCount | countFormat}}
                </div>
                <div class="play-btn pointer">
                    <i class="el-icon-caret-right"></i>
                </div>
            </div>
            <div class="title-line text-hidden font-14 pointer" @click="toMvdetail(item.id)">{{item.name}}</div>
            <div class="author-line font-12">
                <span class="mright-5">{{item.artistName}}</span>
            </div>
        </li>
    </ul>
  </div>
</template>

<script>
export default {
    props:['list','disable'],
    watch:{
        'list.length'(val){
            if(val === 8){
                this.$emit('loadMore',this.list.lenght);
            }
        }
    },
    methods:{
        load(){
            this.$emit('loadMore',this.list.length);
        },
        toMvdetail(id){
            this.$router.push('/videodetail/mv/' + id);
        }
    }
}
</script>

<style lang="less" scoped>
.el-image{
  cursor: pointer;
}
.mv-list {
  ul {
    display: flex;
    flex-wrap: wrap;
    li {
      width: 22%;
      margin-right: 3%;
      .title-line {
        margin: 4px 0;
      }
      .author-line {
        margin: 2px 0;
        color: #676767;
      }
    }
  }
}
.img-wrap{
    position: relative;
    .video-playcount {
        color: #ffffff;
        position: absolute;
        right: 10px;
        top: 10px;
        .icon{
            font-size: 12px;
        }
    }
    .play-btn{
        position: absolute;
        top: 50%;
        left: 50%;
        transform: translate(-50%,-50%);
        background-color: #fbf6f7;
        color: #ec4141;
        width: 40px;
        height: 40px;
        line-height: 40px;
        text-align: center;
        border-radius: 50%;
        opacity: 0;
        transition: all 0.5;
        i{
            font-size: 20px;
        }
    }
    &:hover .play-btn{
        opacity: 1;
    }
}
@media screen and (max-width: 415px) {
  .mv-list {
    ul {
      li {
        width: 48%;
        margin-right: 4%;
        &:nth-child(2n) {
          margin-right: 0;
        }
      }
    }
  }
}
</style>